<div ng-repeat="(radioName, radioStatus) in View.wifiStatus track by radioStatus.phy | orderBy:'phy'">
	<h4>{{radioStatus.hardwareName}}</h4>

	<fieldset class="cbi-section">
		<div class="l2-grid l2-grid-hover">
			<div class="row">
				<div class="cell clearfix content col-xs-12 col-sm-12 col-md-9 col-lg-9">
					<!-- radio header -->
					<span ng-switch on="radioStatus.channel === undefined">
						<span ng-switch-when="true">
							<span class="badge pull-left"><img src="/luci-ng/icons/wifi_disabled.png"> {{radioName}}</span>
							<em class="block-right">Radio is disabled or not associated</em>
						</span>
						<span ng-switch-when="false">
							<span class="badge pull-left"><img src="/luci-ng/icons/wifi.png"> {{radioName}}</span>
							<span class="block-right" ng-if="radioStatus.channel > 0">
								<span class="nowrap"><strong>Channel: </strong>{{radioStatus.channel}} ({{radioStatus.frequency / 1000 | number:3}} GHz) | </span>
								<span class="nowrap"><strong>TX Power: </strong>{{radioStatus.txpower}} dBm</span>
							</span>
						</span>
					</span>
					<!-- / radio header -->
				</div><div class="cell clearfix content col-xs-9 col-sm-9 col-md-3 col-lg-3">
					<div class="btn-group pull-right">
						<button class="btn btn-sm btn-success" ng-click="View.scanWireless(radioName)">Scan…</button><button class="btn btn-sm btn-default" ng-click="View.addSSID(radioName)">Add SSID…</button>
					</div>
				</div>
			</div>
			<div class="row" ng-repeat="ifaceStatus in radioStatus.interfaces track by ifaceStatus.ifname">
				<div class="cell clearfix content col-xs-12 col-sm-12 col-md-9 col-lg-9">
					<!-- signal badge -->
					<span ng-switch on="ifaceStatus.signal === undefined">
						<span ng-switch-when="true" class="badge pull-left" title="No signal">
							<img src="/luci-ng/icons/signal-none.png">
							{{ifaceStatus.ifname}}
						</span>
						<span ng-switch-when="false" class="badge pull-left" title="Signal: {{ifaceStatus.signal}} dBm / Noise: {{ifaceStatus.noise}} dBm">
							<span ng-switch on="(-1 * (ifaceStatus.noise - ifaceStatus.signal)) / 5 | number:0">
								<img ng-switch-when="0" src="/luci-ng/icons/signal-0.png">
								<img ng-switch-when="1" src="/luci-ng/icons/signal-0-25.png">
								<img ng-switch-when="2" src="/luci-ng/icons/signal-25-50.png">
								<img ng-switch-when="3" src="/luci-ng/icons/signal-50-75.png">
								<img ng-switch-default src="/luci-ng/icons/signal-75-100.png">
							</span>
							{{ifaceStatus.ifname}}
						</span>
					</span>
					<!-- / signal badge -->

					<span class="block-right">
						<em ng-if="ifaceStatus.isStarting" translate>Radio interface is starting…</em>
						<em ng-if="ifaceStatus.isStopping" translate>Radio interface is shutting down…</em>

						<span ng-if="!ifaceStatus.isStarting && !ifaceStatus.isStopping">
							<span class="nowrap"><strong>Mode: </strong>{{ifaceStatus.mode}} | </span>
							<span class="nowrap" ng-if="ifaceStatus.bitrate"><strong>Bitrate: </strong>~ {{ifaceStatus.bitrate / 1000 | number:1}} Mbit/s | </span>
							<span class="nowrap"><strong>SSID: </strong>{{ifaceStatus.ssid}} | </span>
							<span class="nowrap" ng-if="ifaceStatus.bssid"><strong>BSSID: </strong>{{ifaceStatus.bssid}} | </span>
							<span class="nowrap"><strong>Encryption: </strong>{{ifaceStatus.encryptionName}}</span>
						</span>
					</span>
				</div><div class="cell clearfix content col-xs-9 col-sm-9 col-md-3 col-lg-3">
					<div class="btn-group pull-right" uib-dropdown>
						<button class="btn btn-sm btn-primary" ng-click="View.renderWirelessMap(ifaceStatus.radio, ifaceStatus.section).show()">Configure</button><button class="btn btn-default btn-sm uib-dropdown-toggle" uib-dropdown-toggle>Action…</button>
						<ul class="dropdown-menu pull-right">
							<li ng-switch on="ifaceStatus.up === true">
								<a ng-switch-when="true" href="#" ng-click="View.enableDisableNetwork(false, ifaceStatus); $event.preventDefault()">Shutdown network</a>
								<a ng-switch-when="false" href="#" ng-click="View.enableDisableNetwork(true, ifaceStatus); $event.preventDefault()">Enable network</a>
							</li>
							<li><a href="#" ng-click="View.deleteSSID(ifaceStatus); $event.preventDefault()">Delete network</a></li>
						</ul>
					</div>
				</div>
			</div>
		</div>
	</fieldset>
</div>

<script type="text/ng-template" id="network/wireless/scan.html">
	<div class="modal-header">
		<h4 translate>Scanning Wireless Networks</h4>
	</div>
	<div class="modal-body">
		<div class="alert alert-info" ng-if="Dialog.isScanning" translate>Waiting for scan results…</div>
		<div class="alert alert-warning" ng-if="!Dialog.isScanning && !Dialog.scanResults.length" translate>Unable to find any networks in range.</div>

		<div class="row" ng-if="Dialog.scanResults.length">
			<div class="col-xs-3 col-md-2"><strong translate>Signal</strong></div>
			<div class="hidden-xs col-md-1"><strong translate-context="Wireless channel abbreviation" translate>Ch.</strong></div>
			<div class="col-xs-4"><p><strong translate>SSID</strong></p></div>
			<div class="col-xs-3"><strong translate>Encryption</strong></div>
			<div class="col-xs-2"><strong translate>Actions</strong></div>
		</div>

		<div class="row" ng-repeat="scanResult in Dialog.scanResults track by scanResult.bssid | orderBy:['channel', 'ssid']">
			<div class="col-xs-3 col-md-2">
				<span class="badge pull-left">
					<span ng-switch on="(5 / scanResult.quality_max) * scanResult.quality | number:0">
						<img ng-switch-when="0" src="/luci-ng/icons/signal-0.png">
						<img ng-switch-when="1" src="/luci-ng/icons/signal-0-25.png">
						<img ng-switch-when="2" src="/luci-ng/icons/signal-25-50.png">
						<img ng-switch-when="3" src="/luci-ng/icons/signal-50-75.png">
						<img ng-switch-default src="/luci-ng/icons/signal-75-100.png">
					</span>
					{{scanResult.signal}} dB
				</span>
			</div>
			<div class="hidden-xs col-md-1">
				{{scanResult.channel}}
			</div>
			<div class="col-xs-4">
				<p>
					<span ng-if="scanResult.ssid.length">{{scanResult.ssid}}</span>
					<em ng-if="!scanResult.ssid.length" translate>Hidden network</em>
				</p>
			</div>
			<div class="col-xs-3">
				{{scanResult.encryption | wifiEncryption:true}}
			</div>
			<div class="col-xs-2">
				<button class="btn btn-xs btn-success" translate-context="Wireless network action" translate ng-click="Dialog.connect(scanResult)">Connect…</button>
			</div>
		</div>
	</div>
	<div class="modal-footer">
		<button class="btn btn-info" translate-context="Wireless network action" translate ng-click="Dialog.scan()" ng-disabled="Dialog.isScanning">Update scan results</button>
		<button class="btn btn-default" translate ng-click="Dialog.dismiss()">Close</button>
	</div>
</script>

<script type="text/ng-template" id="network/wireless/delete.html">
	<div class="modal-header">
		<h4 translate>Deleting Wireless Network</h4>
	</div>
	<div class="modal-body">
		<p translate>
			Really remove the wireless network "{{Dialog.ifaceStatus.ssid.length ? Dialog.ifaceStatus.ssid : Dialog.ifaceStatus.bssid}}"?
		</p>
		<div class="alert alert-danger" translate>
			The deletion cannot be undone!
		</div>
	</div>
	<div class="modal-footer">
		<button class="btn btn-default" translate ng-click="Dialog.dismiss()">Cancel</button>
		<button class="btn btn-danger" translate-context="Wireless network action" translate ng-click="Dialog.confirm()">Delete</button>
	</div>
</script>
